import mpx from '@mpxjs/core'
import fetch from '@mpxjs/fetch'

mpx.use(fetch)

export const get = (url, params = {}) => {
  return mpx.xfetch.fetch({
    url,
    params,
    method: 'GET',
    emulateJSON: true,
    responseType: 'text',
    dataType: 'json'
  }).then(resp => resp.data)
}

export const post = (url, data = {}) => {
  return mpx.xfetch.fetch({
    url,
    data,
    method: 'POST',
    emulateJSON: true,
    responseType: 'text',
    dataType: 'json'
  }).then(resp => resp.data)
}
